package com.iooiee.adapter_pattern.strategy;

public class BinarySearch {
    public int binarySearch(int array[],int key){
        int low = 0;
        int high = array.length - 1;
        while(low <= high){
            int mid = (low + high) / 2;
            int midval = array[mid];
            if(midval < key){
                low = mid +1;
            }else if(midval > key){
               high = mid -1 ;
            }else {
                return 1;
            }
        }
        return -1;
    }
}
